/*
 * @Description: 谷歌分析
 * @Author: kanglin
 * @Date: 2018-08-10 17:56:47
 * @Copyright: Created by PanxSoft.
 */
import API_LIST from 'src/API_LIST';
// import dataLayer from 'dataLayer';
// const dataLayer = window.dataLayer;
const ID = 'UA-90011411-7';
const dataLayer = window.dataLayer || [];


function gTag() {
	if (!API_LIST.APP_DEBUG) {
		dataLayer.push(arguments); // eslint-disable-line
	}
}

gTag('js', new Date());
gTag('config', ID);

window.addEventListener('error', evt => {
  /**
   * @link https://developers.google.com/analytics/devguides/collection/gtagjs/events?hl=zh-cn
   */
  gTag('event', evt.error.stack, {
    event_category: 'window.error',
    event_label: navigator.userAgent
  })
});

export default gTag;
